"""
元组：
一旦定义完成，就不可修改，只读的list
如果元组中只有一个元素，需要("a",) 加逗号
"""
# 定义元组
t = ("aaa", 1, 2, "bbb")
t1 = ()
t2 = tuple()
print(type(t), "内容是", t2)

t3 = ("a")
print(type(t3))  # str
t4 = ("a",)
print(type(t4))  # tuple

# 元组的嵌套
t5 = ((1, 2, 3), (4, 5, 6))
print(type(t5))

print("下标索引取出元素：", t5[1][2])

print("按元素获取索引", t5.index((4, 5, 6)))
print("获取某个元素个数", t5.count((4, 5, 6)))
print("获取元素个数", len(t5))

print("=====================元组的遍历================")
stat = 0
while stat < len(t5):
    print(t5[stat])
    stat += 1

print("==================for循环=======================")

for t in t5:
    print(t)

# 元素中list可以被修改
l = ["aa", 'bb']

t = (1, 2, l)

del l[0]

print(t)
